package com.easy.controller;

import com.easy.bean.Itinerary_detail;
import com.easy.service.Itinerary_detailService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin // 允许跨域访问
@RequestMapping("/itinerary_detail")
public class Itinerary_detailController {
    @Autowired
    Itinerary_detailService itinerary_detailService;

    @PostMapping
    public Result add(@RequestBody Itinerary_detail itinerary_detail){
        Object obj = itinerary_detailService.add(itinerary_detail);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Itinerary_detail itinerary_detail){
        Object obj = itinerary_detailService.edit(itinerary_detail);
        return Result.success(obj);
    }

    @DeleteMapping("/{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj = itinerary_detailService.del(id);
        return Result.success(obj);
    }

    @GetMapping("/{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj = itinerary_detailService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Itinerary_detail itinerary_detail){
        Object obj = itinerary_detailService.all(itinerary_detail);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, Itinerary_detail itinerary_detail){
        itinerary_detailService.page(page, itinerary_detail);
        return Result.success(page);
    }
    @GetMapping("pageWithDetails")
    public Result pageWithDetails(Page page, Itinerary_detail itinerary_detail){
        itinerary_detailService.pageWithDetails(page, itinerary_detail);
        return Result.success(page);
    }
}
